#pragma once

#include <string>
#include <vector>
#include "WnQueue.h"
#include <algorithm>
#include "types.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <string>

enum DATA_TYPE
{
  FH_NA,        // invalid type
  FH_DOUBLE,    // double
  FH_INT64,     // int64_t
  FH_INT32,     // int32_t
  FH_CHAR,      // char
  FH_STRING     // string
};

enum DBF_UPDATE_METHOD
{
  ADD,
  MODIFY
};

enum FIELD_UPDATE_MODE
{
  EACH,
  ONCE,
  INCREMENTAL
};

// xml node structure of dbf
class DBF_Xml_Node_Struct
{
public:
  typedef std::vector<DBF_Xml_Node_Struct*> ARR_NODE;
public:
  DBF_Xml_Node_Struct()
  {
    wind_index = 0;
    enable = 0;
  }
  ~DBF_Xml_Node_Struct()
  {
    ARR_NODE::iterator it;
    for(it = arrField.begin(); it != arrField.end(); ++it)
    {
      delete *it;
      *it = NULL;
    }
  }
public:
  std::string field_name;
  int32_t wind_index;
  int8_t enable;
  std::string dbf_path;
  ARR_NODE arrField;
};

template<class T> class deque_ex : public CWnQueue<T>
{
public:
  deque_ex(){}
  ~deque_ex(){}
public:
  size_type count(T val)
  {
    size_type size = 0;
    for(iterator it = begin(); it != end(); ++it)
    {
      if( val == *it )
        ++size;
    }
    return size;
  }

  void unique()
  {
		CWnScopedLock lock(*m_ptr_mutex);
    iterator it = std::unique(begin(), end());
    erase(it, end());
  }
};

class FILEINFO
{
public:
  FILEINFO() {}
  ~FILEINFO() {}
public:
  boost::posix_time::time_duration time;
  std::string md5_code;
};